package base.proxy;

import java.lang.reflect.Proxy;

public class MyProxyFactory {
	
	public static Object getProxy(Object object){
		ProxyHandler handler=new ProxyHandler();
		
		handler.setTarget(object);
		
		return Proxy.newProxyInstance(object.getClass().getClassLoader(),object.getClass().getInterfaces(),	handler);
	}
	
	public static void main(String[] args) {
		Dog target=new DogImpl();
		
		Dog dog=null;
		
		Object proxy=MyProxyFactory.getProxy(target);
		
		if(proxy instanceof Dog){
			dog=(Dog) proxy;
		}
		dog.info();
		dog.run();
		
	}
}
